import {request} from "@/utils/request";

/**
 * 获取文章分组
 */
export function selectArticleGroup(){
    return request({
      url: '/blog/web/group/select/all',
      method : 'get',
      headers: {
            isToken: false
      },
    })
}

/**
 *  获取文章列表
 * @param userId
 * @param type
 * @param pageNum
 * @param pageSize
 * @returns {*}
 */
export  function selectPageArticles(userId,type,pageNum,pageSize){
       const query ={
           userId,
           type,
           pageNum,
           pageSize
       }
    return request({
      url: '/blog/web/article/select/list',
      method: 'get',
      headers: {
            isToken: false
      },
      params:query
    })
}

/**
 * 获取文章列表热度榜
 *
 */
export function selectHotArticles(){
     return request({
         url: '/blog/web/article/select/hot',
         method: 'get',
         headers: {
             isToken: false
         },
     })
}

/**
 * 获取文章点赞数
 */
export function getArticleLikeNum(articleId){
    const query = {articleId}
    return request({
        url: '/blog/web/article/select/like/num',
        method:'get',
        headers: {
            isToken: false
        },
        params:query
    })
}


/**
 * 获取文章收藏数
 */
export function getArticleCollectNum(articleId){
    const query = {articleId}
    return request({
        url: '/blog/web/article/select/collect/num',
        method:'get',
        headers: {
            isToken: false
        },
        params:query
    })
}

/**
 * 获取文章推荐
 */
export function selectArticleRecommend(userId){
    const query = {userId}
    return request({
        url: '/blog/web/article/get/recommend',
        method:'get',
        params:query,
    })
}

/**
 * 根据获取id获取文章详情
 */
export  function getArticleById(articleId){
    const query = {articleId}
    return request({
        url: '/blog/web/article/select/detail',
        method: 'get',
        headers: {
            isToken: false
        },
        params:query
    })
}



/**
 * 文章评分
 */
export function getArticleRate({rate,articleId}){
    const query = {
        rate,
        articleId
    }
    return request({
        url: '/blog/web/article/rate',
        method: 'get',
        params:query
    })
}
